package com.hiwhitley.easy.day24;

import java.util.TreeSet;

/**
 * Created by hiwhitley on 2016/10/17.
 */
public class RejectRepeatedChars {
    public String rejectRepeatedChars(String strInput) {
        if (strInput == null || strInput.length()==1)
            return strInput;
        TreeSet<String> set = new TreeSet<>();
        String[] split = strInput.split("");
        for (String s : split) {
            set.add(s);
        }

        StringBuilder sb = new StringBuilder();
        for (String s : set) {
            sb.append(s);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        RejectRepeatedChars main = new RejectRepeatedChars();
        System.out.println(main.rejectRepeatedChars("aaabbbcccaaa"));
    }
}
